package com.zekdot.userclient.action;

import com.zekdot.userclient.dto.Envelope;
import com.zekdot.userclient.util.LogUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Create by zekdot on 20-3-20.
 */
@ControllerAdvice
@ResponseBody
public class ExceptionHandler {

    @Autowired
    private LogUtil logUtil;
    @org.springframework.web.bind.annotation.ExceptionHandler
    public String handleException(Exception exception){
        logUtil.writeError(exception);
        return new Envelope(-100,"服务器出现了未预料到的错误，已写入日志中，我们会尽快处理",null).toString();
    }
}
